package com.example.ywj.toutiao.utils;

import android.graphics.Typeface;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import android.widget.TextView;
import com.example.ywj.toutiao.R;
import com.example.ywj.toutiao.bean.Set;

import java.util.List;

public class SetAdapter2 extends BaseAdapter {
    public List<Set> list;
    private String baseUrl = Constant.BASEURL;
    public SetAdapter2(List<Set> list){
        this.list = list;
    }
    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder ;
        if(convertView == null) {
            LayoutInflater inflater = LayoutInflater.from(parent.getContext());
            convertView = inflater.inflate(R.layout.edit_layout_item2, null);
            viewHolder = new ViewHolder();
            viewHolder.tv1 = convertView.findViewById(R.id.edit_item2_title);
            viewHolder.tv2 = convertView.findViewById(R.id.edit_item2_value);
            viewHolder.tv3 = convertView.findViewById(R.id.edit_item2_next);
            convertView.setTag(viewHolder);
        }else{
            viewHolder = (ViewHolder)convertView.getTag();
        }
        viewHolder.tv1.setText(list.get(position).getKey());
        Typeface font = Typeface.createFromAsset(convertView.getContext().getAssets(), "iconfont.ttf");
        viewHolder.tv3.setTypeface(font);
        viewHolder.tv3.setText(convertView.getContext().getResources().getString(R.string.go));
        viewHolder.tv2.setText(list.get(position).getValue());
        return convertView;
    }
    class ViewHolder{
        TextView tv1;
        TextView tv2;
        TextView tv3;
    }
}
